<template>
  <div class="local-temp">
    <div class="local-city" @click="handleRotate">
      <div class="city">{{ localCity || '加载中...' }}</div>
      <i class="iconfont icon-sanjiaoxing" :class="{ rotated: isRotated }"></i>
    </div>
    <div class="weather">
      <div class="top">{{ localLemplete[2] || '暂无数据' }}</div>
      <div class="top">{{ localLemplete[1] }}/{{ localLemplete[0] }}°C</div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const isRotated = ref(false)

const handleRotate = () => {
  isRotated.value = !isRotated.value
}

const props = defineProps({
  localCity: {
    type: String,
    default: '铜仁'
  },
  localLemplete: {
    type: Array,
    default: () => ['30', '20', '晴']
  },
})

  
</script>

<style lang="scss" scoped>
.local-temp {
  position: absolute;
  top: 20px;
  left: 400px;
  display: flex;
  gap: 10px;
  background: #fff;
  color: #666;
  font-size: 12px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
  padding: 0px 10px;
  .local-city {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 10px 5px;
    cursor: pointer;
    &:hover {
      color: #0091ff;
    }
    i {
      font-size: 8px;
      transition: transform 0.3s;
    }
    .city {
      white-space: nowrap; /* 避免名称换行 */
    }
    // 点击时切换类
    i.rotated {
      transform: rotate(180deg);
    }
  }
  .weather {
    padding: 5px;
    text-align: center;
  }
}
</style>
